Status:  U
Return-Path: <coco-bounces@maltedmedia.com>
Received: from pickering.mail.mindspring.net ([207.69.200.36])
	by mdl-absent.atl.sa.earthlink.net (EarthLink SMTP Server) with SMTP id 1qpOy47oV3Nl36W0; Fri, 27 May 2011 00:21:20 -0400 (EDT)
Received: from five.pairlist.net ([216.92.1.121])
	by pickering.mail.mindspring.net (EarthLink SMTP Server) with ESMTP id 1qpOy3zG3Nl3p20
	for <sfischer1@mindspring.com>; Fri, 27 May 2011 00:21:19 -0400 (EDT)
Received: from five.pairlist.net (localhost [127.0.0.1])
	by five.pairlist.net (Postfix) with ESMTP id EEA1A3BDA7;
	Fri, 27 May 2011 00:21:17 -0400 (EDT)
X-Original-To: coco@lists5.maltedmedia.com
Delivered-To: coco@five.pairlist.net
Received: from deploy5.pair.com (qs281.pair.com [216.92.131.37])
	by five.pairlist.net (Postfix) with SMTP id C0A4F3BD96
	for <coco@lists5.maltedmedia.com>; Fri, 27 May 2011 00:21:16 -0400 (EDT)
Received: (qmail 18492 invoked by uid 3002); 27 May 2011 04:21:17 -0000
Delivered-To: bathory-maltedmedia:com-coco@maltedmedia.com
Received: (qmail 18488 invoked from network); 27 May 2011 04:21:17 -0000
Received: from localhost.pair.com (HELO qs281.pair.com) (127.0.0.1)
	by localhost.pair.com with SMTP; 27 May 2011 04:21:17 -0000
Received: from localhost (localhost [127.0.0.1])
	by qs281.pair.com (Postfix) with SMTP id 27375D4C5A
	for <coco@maltedmedia.com>; Fri, 27 May 2011 00:21:17 -0400 (EDT)
X-Virus-Check-By: qs281.pair.com
X-Spam-Check-By: qs281.pair.com
X-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,
	SPF_HELO_PASS autolearn=ham version=3.002005
X-Spam-Flag: NO
X-Spam-Level: 
X-Spam-Filtered: 2339d97e2cf80afbc3f9b452dd9fb067
Received: from svc.ocs.net (ocs.net [208.46.202.201])
	by qs281.pair.com (Postfix) with ESMTP id 8CDD6D4C59
	for <coco@maltedmedia.com>; Fri, 27 May 2011 00:21:15 -0400 (EDT)
Received: from [172.16.1.14] (c-67-160-192-154.hsd1.ca.comcast.net
	[67.160.192.154]) (using TLSv1 with cipher AES128-SHA (128/128 bits))
	(No client certificate requested) (Authenticated sender: n6il)
	by svc.ocs.net (Postfix) with ESMTPSA id 87883D25F4B
	for <coco@maltedmedia.com>; Thu, 26 May 2011 21:21:14 -0700 (PDT)
Mime-Version: 1.0 (Apple Message framework v1084)
From: Michael Furman <n6il@ocs.net>
In-Reply-To: <9B6B5EC6-BC3F-4088-B92E-7A47ABA349BA@ocs.net>
Date: Thu, 26 May 2011 21:21:13 -0700
Message-Id: <58F4A574-8CFE-4C17-914B-FF1290BDC67A@ocs.net>
References: <20110524212513.GA6439@brawl.fslf.org>
	<201105250032.09184.gheskett@wdtv.com>
	<A7EEA425FE814B7CA062FA0D5F10BCFD@Shasta>
	<20110525195346.GC14480@brawl.fslf.org>
	<9B6B5EC6-BC3F-4088-B92E-7A47ABA349BA@ocs.net>
To: CoCoList for Color Computer Enthusiasts <coco@maltedmedia.com>
X-Mailer: Apple Mail (2.1084)
Subject: Re: [Coco] cprep19 __FILE__ fix?
X-BeenThere: coco@maltedmedia.com
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: CoCoList for Color Computer Enthusiasts <coco@maltedmedia.com>
List-Id: CoCoList for Color Computer Enthusiasts <coco.maltedmedia.com>
List-Unsubscribe: <http://five.pairlist.net/mailman/listinfo/coco>,
	<mailto:coco-request@maltedmedia.com?subject=unsubscribe>
List-Archive: <http://five.pairlist.net/pipermail/coco/>
List-Post: <mailto:coco@maltedmedia.com>
List-Help: <mailto:coco-request@maltedmedia.com?subject=help>
List-Subscribe: <http://five.pairlist.net/mailman/listinfo/coco>,
	<mailto:coco-request@maltedmedia.com?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: coco-bounces@maltedmedia.com
Errors-To: coco-bounces@maltedmedia.com
X-ELNK-Received-Info: spv=0;
X-ELNK-AV: 0
X-ELNK-Info: sbv=1; sbrc=-0; sbf=e0; sbw=000;

On May 25, 2011, at 2:49 PM, Michael Furman wrote:

> Willard, I looked into this a few months ago.  Off the top of my haead:
> 
> 1) I have some source for the Krieder C library, but when I assembled it, it was not exactly the same as binary copies floating around.  This reduces my confidence that the resulting clib after hacking will actually work properly, and makes it difficult to generate a patch that will always work.  The date command returns the correct year.
> 
> 2) clib's asctime function had some contribution to the problem but the details escape me ATM.

Got time to look at this tonight. First, The date problem contribution from kriederlib is as follows:

00001550  76 00 44 65 63 00 25 73  20 25 73 20 25 32 64 20  |v.Dec.%s %s %2d |
00001560  25 30 32 64 3a 25 30 32  64 3a 25 30 32 64 20 31  |%02d:%02d:%02d 1|
00001570  39 25 30 32 64 0d 00 00  1f 00 1c 00 1f 00 1e 00  |9%02d...........|

So roughly, the library's asctime function calls:

sprintf(buf, "%s %s %2d %02d:%02d:%02d 19%02d",
	days[day_of_week],
	months[t_month],
	t_day,
	t_hour,
	t_minute,
	t_second,
	t_year );

Which will result in

Thu May 26 21:05:52 19111

I haven't fixed this yet because of item #2...

We have to be careful on relying on raw-disassembly of things, it can be quite confusing, and sometimes results in errors.  The nitros9 build system generates quite a few disk images based on disassemblies.  I know that some of them have been confirmed to be exactly the same as the original... but in this case, it's wrong.

The following is code from utime.a module in krieder c lib prepares the month arguments for sprintf:  loads the index in D, subtract 1, multiplies it by 4, gets the address of the month table in X, adds them and pushes the result to the stack as an argument for sprintf:

00311 01e7 ec48                ldd   8,u         
00312 01e9 830001              subd  #1          
00313 01ec 58                  lslb              
00314 01ed 49                  rola              
00315 01ee 58                  lslb              
00316 01ef 49                  rola              
00317 01f0 308d0055            leax  >L024a,pcr  
00318 01f4 308b                leax  d,x         
00319 01f6 3410                pshs  x           

The disassembler turned the table into a bunch of junk.  Note that the label L024a is actually at 0249 (??)

00361 0248 044a                lsr   D.SysPrc    
00362 0249            L024a    equ   *-1         
00363 024a 61                  fcb   $61         
00364 024b 6e                  fcb   $6e         
00365 024c 0046                neg   D0046       
00366 024e 65                  fcb   $65         
00367 024f 62                  fcb   $62         
00368 0250 004d                neg   D004d       
00369 0252 61                  fcb   $61         
00370 0253 72                  fcb   $72         
00371 0254 0041                neg   D0041       
00372 0256 707200              neg   X7200       
00373 0259 4d                  tsta              
00374 025a 61                  fcb   $61         
00375 025b 094a                rol   D.SysPrc    
00376 025d 75                  fcb   $75         
00377 025e 6e                  fcb   $6e         
00378 025f 004a                neg   D004a       
00379 0261 75                  fcb   $75         
00380 0262 6c                  fcb   $6c         
00381 0263 0041                neg   D0041       
00382 0265 75                  fcb   $75         
00383 0266 67                  fcb   $67         
00384 0267 0053                neg   D0053       
00385 0269 65                  fcb   $65         
00386 026a 004f                neg   X004f       
00387 026c 6374                com   -12,s       
00388 026e 004e                neg   D004e       
00389 0270 6f76                clr   -10,s       
00390 0272 0044                neg   D0044       
00391 0274 65                  fcb   $65         
00392 0275 63                  fcb   $63         
00393 0276 0025                neg   D0025       

This junk has some errors if we look at it with hexdump, we want 4a 61 6e 00 etc.

000002ba                                 4a 61 6e 00 46 65  |          Jan.Fe|
000002c0  62 00 4d 61 72 00 41 70  72 00 4d 61 09 4a 75 6e  |b.Mar.Apr.Ma.Jun|
000002d0  00 4a 75 6c 00 41 75 67  00 53 65 00 4f 63 74 00  |.Jul.Aug.Se.Oct.|
000002e0  4e 6f 76 00 44 65 63 00                           |Nov.Dec.        |

So May, and September are truncated.  Based on the code this will result in some bugs.  A human would write something like this.  Note that these are C-Style NUL terminated strings so we can't use FCS for them:

00377 024a            L024a                      
00378 024a 4a616e              fcc   /Jan/       
00379 024d 00                  fcb   $00         
00380 024e 466562              fcc   /Feb/       
00381 0251 00                  fcb   $00         
00382 0252 4d6172              fcc   /Mar/       
00383 0255 00                  fcb   $00         
00384 0256 417072              fcc   /Apr/       
00385 0259 00                  fcb   $00         
00386 025a 4d6179              fcc   /May/       
00387 025d 00                  fcb   $00         
00388 025e 4a756e              fcc   /Jun/       
00389 0261 00                  fcb   $00         
00390 0262 4a756c              fcc   /Jul/       
00391 0265 00                  fcb   $00         
00392 0266 417567              fcc   /Aug/       
00393 0269 00                  fcb   $00         
00394 026a 536570              fcc   /Sep/       
00395 026d 00                  fcb   $00         
00396 026e 4f6374              fcc   /Oct/       
00397 0271 00                  fcb   $00         
00398 0272 4e6f76              fcc   /Nov/       
00399 0275 00                  fcb   $00         
00400 0276 446563              fcc   /Dec/       
00401 0279 00                  fcb   $00         

Fixed, 

000002bb                                    4a 61 6e 00 46  |           Jan.F|
000002c0  65 62 00 4d 61 72 00 41  70 72 00 4d 61 79 00 4a  |eb.Mar.Apr.May.J|
000002d0  75 6e 00 4a 75 6c 00 41  75 67 00 53 65 70 00 4f  |un.Jul.Aug.Sep.O|
000002e0  63 74 00 4e 6f 76 00 44  65 63 00                 |ct.Nov.Dec.     |

I have to finish fixing everything before I can proceed with fixing the date problem.

--
Coco mailing list
Coco@maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco